<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="../js/axios.min.js"></script>
    <script src="../js/api.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      a {
        text-decoration: none;
      }
      .caini_inner {
        width: 1200px;
        margin: 0 auto;
        /* background: red; */
      }
      .caini_inner > h3 {
        margin-left: 15px;
        margin-bottom: 20px;
      }
      .caini_inner_box {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-around;
      }
      .caini_inner_box img {
        width: 270px;
      }
      .caini_inner_box div {
        width: 260px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
      }
      .caini_inner_box > div > a > h4 {
        color: red;
        font-size: 16px;
        margin-left: 3px;
      }
      .caini_inner_box > div > a > h4 > span {
        font-size: 14px;
      }
      .caini_inner_box > div > a > p {
        margin-top: 5px;
        margin-left: 5px;
        font-size: 12px;
        color: #111;
      }

      .caini_inner_box > div > a > span {
        margin-left: 5px;
        font-size: 12px;
        color: gray;
      }
    </style>
  </head>
  <body style="background-color: #f4f4f4">
    <div class="caini">
      <div class="caini_inner">
        <h3>猜你喜欢</h3>
        <div class="caini_inner_box"></div>
      </div>
    </div>
  </body>
  <script>
    axios
      .get(proudtListAPI, { params: { pagesize: 100, pagenum: 0 } })
      .then((res) => {
        let productArr = res.data.data;
        console.log(productArr);
        let resArr = productArr.filter((i) => i.pname.indexOf("瑞士") != -1);
        console.log(resArr);
        let strArr = resArr.map(
          (e) => `<div> 
          <a href="./item.html?${e.id}">
          <img src="${e.pimg}" alt="" />
          <h4><span>￥</span>${e.pprice}</h4>
          <p>${e.pdesc}</p>
          <span>${e.pname}</span>
          </a>
          </div>`
        );
        $(".caini_inner_box").html(strArr.join(""));
      });
  </script>
</html>
